package com.ygqh.baby.service.impl;
import java.util.List;
import  com.ygqh.baby.ao.QueryInfo;
import  com.ygqh.baby.ao.ResultSet;
import  com.ygqh.baby.po.YgOrderTrackDetail;
import  com.ygqh.baby.mapper.YgOrderTrackDetailMapper;
import  com.ygqh.baby.service.YgOrderTrackDetailService;
import  org.springframework.util.Assert;
import java.util.Arrays;
import  org.springframework.stereotype.Service;
import  org.springframework.beans.factory.annotation.Autowired;

import  com.ygqh.baby.po.YgOrderTrackDetailExample;
import  com.ygqh.baby.ao.DataStatus;

@Service
public class YgOrderTrackDetailServiceImpl implements YgOrderTrackDetailService{
	
	@Autowired
	private YgOrderTrackDetailMapper ygOrderTrackDetailMapper;
	
	@Override
	public List<YgOrderTrackDetail> find() {
		YgOrderTrackDetailExample example = new YgOrderTrackDetailExample();		
		return ygOrderTrackDetailMapper.selectByExample(example);
	}

	@Override
	public int findCount() {
		YgOrderTrackDetailExample example = new YgOrderTrackDetailExample();		
		return ygOrderTrackDetailMapper.countByExample(example);
	}

	@Override
	public YgOrderTrackDetail findById(Long id) {
		return ygOrderTrackDetailMapper.selectByPrimaryKey(id);
	}


	

	@Override
	public int save(YgOrderTrackDetail ygOrderTrackDetail) {
		return ygOrderTrackDetailMapper.insertSelective(ygOrderTrackDetail);
	}

	@Override
	public int update(YgOrderTrackDetail ygOrderTrackDetail) {
		return ygOrderTrackDetailMapper.updateByPrimaryKeySelective(ygOrderTrackDetail);
	}

	@Override
	public ResultSet<YgOrderTrackDetail> search(QueryInfo queryInfo,String q) {
		List<YgOrderTrackDetail>  list =  ygOrderTrackDetailMapper.selectSuper(queryInfo, q);
		int count = ygOrderTrackDetailMapper.countSuper(q);
		ResultSet<YgOrderTrackDetail> resultSet = new ResultSet<YgOrderTrackDetail>(count,list);
		return resultSet;
	}

	@Override
	public int deleteSoft(Long[] ids) {
		Assert.notEmpty(ids);
		YgOrderTrackDetailExample example = new YgOrderTrackDetailExample();
		example.createCriteria().andIdIn(Arrays.asList(ids));
		YgOrderTrackDetail record = new YgOrderTrackDetail();
		return ygOrderTrackDetailMapper.updateByExampleSelective(record, example);
	}
	
	@Override
	public int deleteSoft(Long id) {
		return this.deleteSoft(new Long[]{id});
	}

	@Override
	public int saveOrUpdate(YgOrderTrackDetail ygOrderTrackDetail) {
		int r = 0;
		if(ygOrderTrackDetail.getId() != null) {
			r = this.update(ygOrderTrackDetail);
		}else {
			r = this.save(ygOrderTrackDetail);
		}
		return r;
	}

}

